export default function request(options) {
	 //后端接口地址
	const baseUrl = 'https://lzt.chengke.net/app-api';
	// const baseUrl = 'http://127.0.0.1:48080/app-api';
	const token = uni.getStorageSync("token")
	const {
		method,
		url,
		data,
		header
	} = options
	return new Promise((resolve, reject) => {
		uni.request({
			method: method,
			url: baseUrl + url,
			data,
			header: {
				"Authorization": token,
				"tenant-id": "1",
				"terminal": "20"
			},
		}).then(response => {
			if(response.code === 401){
				uni.navigateTo({
					url:"/minePages/login"
				})
				return
			}
			let [error, res] = response;
			resolve(res.data);
		}).catch(error => {
			let [err, res] = error;
			reject(err)
		})
	})
}
